//
//  XHCouponsCell.m
//  umibus
//
//  Created by 冷山 on 16/6/17.
//  Copyright © 2016年 lexingsoft. All rights reserved.
//

#import "XHCouponsCell.h"

@interface XHCouponsCell()

@property (nonatomic, strong) NSDictionary * dic;

@end

@implementation XHCouponsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.ui_bgView.layer.borderWidth = 0.5;
    self.ui_bgView.layer.borderColor = [ColorManager colorWithHexString:@"#C4C4C4" alpha:1].CGColor;
    
    self.ui_useButton.layer.masksToBounds = YES;
    self.ui_useButton.layer.cornerRadius = 3;
    self.ui_useButton.layer.borderColor = [ColorManager colorWithHexString:@"#000000" alpha:0.5].CGColor;
    self.ui_useButton.layer.borderWidth = 0.5;
    
    self.ui_sellButton.layer.masksToBounds = YES;
    self.ui_sellButton.layer.cornerRadius = 3;
    self.ui_sellButton.layer.borderColor = [ColorManager colorWithHexString:@"#000000" alpha:0.5].CGColor;
    self.ui_sellButton.layer.borderWidth = 0.5;

    self.ui_examplesButton.layer.masksToBounds = YES;
    self.ui_examplesButton.layer.cornerRadius = 3;
    self.ui_examplesButton.layer.borderColor = [ColorManager colorWithHexString:@"#000000" alpha:0.5].CGColor;
    self.ui_examplesButton.layer.borderWidth = 0.5;

}

- (void)setCouponsUsedType:(NSDictionary*)dic
{
    self.dic = dic;
    if ([dic[@"canPresented"] isEqualToString:@"N"]&&
        [dic[@"canSale"] isEqualToString:@"N"])
    {
        self.ui_useButton.hidden=YES;
        self.ui_sellButton.hidden=YES;
        self.ui_examplesButton.hidden=NO;
        [self.ui_examplesButton setTitle:@"使用" forState:UIControlStateNormal];
        
    }
    else if ([dic[@"canPresented"] isEqualToString:@"Y"]&&
             [dic[@"canSale"] isEqualToString:@"Y"])
    {
        self.ui_useButton.hidden=NO;
        self.ui_sellButton.hidden=NO;
        self.ui_examplesButton.hidden=NO;
        [self.ui_useButton setTitle:@"使用" forState:UIControlStateNormal];
        [self.ui_sellButton setTitle:@"出售" forState:UIControlStateNormal];
        [self.ui_examplesButton setTitle:@"转赠" forState:UIControlStateNormal];
    }
    else if ([dic[@"canPresented"] isEqualToString:@"Y"]&&
             [dic[@"canSale"] isEqualToString:@"N"])
    {
        self.ui_useButton.hidden=YES;
        self.ui_sellButton.hidden=NO;
        self.ui_examplesButton.hidden=NO;
        [self.ui_sellButton setTitle:@"使用" forState:UIControlStateNormal];
        [self.ui_examplesButton setTitle:@"转赠" forState:UIControlStateNormal];
    }
    else if ([dic[@"canPresented"] isEqualToString:@"N"]&&
             [dic[@"canSale"] isEqualToString:@"Y"])
    {
        self.ui_useButton.hidden=YES;
        self.ui_sellButton.hidden=NO;
        self.ui_examplesButton.hidden=NO;
        [self.ui_sellButton setTitle:@"使用" forState:UIControlStateNormal];
        [self.ui_examplesButton setTitle:@"出售" forState:UIControlStateNormal];
    }

}

//第一个按钮
- (IBAction)userAction:(UIButton*)sender
{
    if ([self.dic[@"canPresented"] isEqualToString:@"Y"]&&
             [self.dic[@"canSale"] isEqualToString:@"Y"])
    {
        [_delegate userAction:sender];
    }
}
//第二个按钮
- (IBAction)sellAction:(UIButton*)sender
{
    if ([self.dic[@"canPresented"] isEqualToString:@"Y"]&&
             [self.dic[@"canSale"] isEqualToString:@"Y"])
    {
        [_delegate sellAction:sender];
    }
    else if ([self.dic[@"canPresented"] isEqualToString:@"Y"]&&
             [self.dic[@"canSale"] isEqualToString:@"N"])
    {
        [_delegate userAction:sender];
    }
    else if ([self.dic[@"canPresented"] isEqualToString:@"N"]&&
             [self.dic[@"canSale"] isEqualToString:@"Y"])
    {
        [_delegate userAction:sender];
    }
}
//第三个按钮
- (IBAction)examplesAction:(UIButton*)sender
{
    if ([self.dic[@"canPresented"] isEqualToString:@"N"]&&
        [self.dic[@"canSale"] isEqualToString:@"N"])
    {
        [_delegate userAction:sender];
    }
    else if ([self.dic[@"canPresented"] isEqualToString:@"Y"]&&
             [self.dic[@"canSale"] isEqualToString:@"Y"])
    {
        [_delegate examplesAction:sender];
    }
    else if ([self.dic[@"canPresented"] isEqualToString:@"Y"]&&
             [self.dic[@"canSale"] isEqualToString:@"N"])
    {
        [_delegate examplesAction:sender];
    }
    else if ([self.dic[@"canPresented"] isEqualToString:@"N"]&&
             [self.dic[@"canSale"] isEqualToString:@"Y"])
    {
        [_delegate sellAction:sender];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
